package com.FH.permission.orgnization_menu;
import com.FH.util.ResultDTO;

import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

/**
 * Created by acer on 2016/8/4.
 */
@Path("/orgnizationmenu")
@Produces(MediaType.APPLICATION_JSON)
@RequestScoped
public class OrgnizationmenuResource {

    @EJB
    OrgnizationMenuDAO orgnizationMenuDAO;

    @GET
    @Path("/{search}&{page}&{size}")
    public ResultDTO getOrgnizationMenuInfo(@PathParam("search") String search, @PathParam("page") String page, @PathParam("size") String size) {
        //添加分页查询
        //添加分页查询
        if(null==page||"".equals(page)||"0".equals(page))
        {
            page = "1";	//默认从第0行开始查起
        }
        if(null==size||"".equals(size))
        {
            size = "10";  //每页默认10条数据
        }
        return orgnizationMenuDAO.getOrgnizationMenuInfo(search, page, size);
    }


   @POST
   @Consumes(MediaType.APPLICATION_JSON)
   public ResultDTO addOrgnizationMenuInfo(OrgnizationMenuPullDTO orgnizationMenuPullDTO){
       return orgnizationMenuDAO.addOrgnizationMenuInfo(orgnizationMenuPullDTO);
   }

    @DELETE
    @Consumes(MediaType.APPLICATION_JSON)
    public ResultDTO deleteOrgnizationMenuInfo(OrgnizationMenuPullDTO orgnizationMenuPullDTO){
        return orgnizationMenuDAO.deleteOrgnizationMenuInfo(orgnizationMenuPullDTO);
    }
}
